<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1{
            width: 300px;
            height: 200px;
            background-color: red;
            position: absolute;
            /* calc是一个简单的计算公式
             * calc(50% - 150px)务必要注意的是减号左右要有空格
             */
            left: calc(50% - 150px);
            top: calc(50% - 100px);
        }
    </style>
</head>
<body>
    <div class="box1"></div>
</body>
</html>